//
//  ViewController.m
//  16-AutomaticallyAdjusts
//
//  Created by dllo on 16/8/4.
//  Copyright © 2016年 DM.C. All rights reserved.
//

#import "ViewController.h"
#define kTableViewCell @"reuse"
@interface ViewController ()<UITableViewDelegate, UITableViewDataSource>
@property (weak, nonatomic) IBOutlet UITableView *myTableView;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
//    self.automaticallyAdjustsScrollViewInsets = NO;
    
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 20;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kTableViewCell];
    cell.textLabel.text = @"标题";
    return cell;
}
#pragma mark - 点击cell时触发的方法
/***  ***/
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    // 根据index获取到cell
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
    //根据cell获取到index
//    NSIndexPath *indexpath = [tableView indexPathForCell:cell];
    NSLog(@"点击----%@", cell.textLabel.text);
}
/*** 当触发segue的时候, 会调用这个方法 ***/
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    NSLog(@"%@", sender);
    // 其中的sender相当于点击的cell
    UITableViewCell *cell = sender;
    // segue相当于桥梁,用来沟通两个界面, 由它可调用下一界面的属性
    segue.destinationViewController.title = cell.textLabel.text;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
